import { RequestUtil } from '@/utils/request.js';

const getList = (pageNo, pageSize, searchQuery, sortBy, isAsc) => {
  return RequestUtil.get('/permission', {
    params: {
      pageNo: pageNo,
      pageSize: pageSize,
      sortBy: sortBy,
      isAsc: isAsc,
      ...searchQuery
    }
  });
};

const add = (data) => {
  return RequestUtil.post('/permission', {
    data: data
  });
};

const update = (id, permission) => {
  return RequestUtil.put('/permission', {
    data: {
      permissionId: id,
      ...permission
    }
  });
};

const deleteByIds = (ids) => {
  return RequestUtil.delete('/permission?ids=' + (Array.isArray(ids) ? ids.join(',') : ''));
};

export const PermissionApi = {
  getList,
  add,
  update,
  deleteByIds
};
